Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Objects /
Chapter 4 - Colors and Color-Related Objects


Summary of Colors and Color-Related Objects

Constants and Data Types

Color-Component Values

typedef unsigned short gxColorValue;

Color Values

   struct gxCMYKColor{
      gxColorValue   cyan;
      gxColorValue   magenta;
      gxColorValue   yellow;
      gxColorValue   black;
   };
   struct gxRGBColor{
      gxColorValue   red;
      gxColorValue   green;
      gxColorValue   blue;
   };
   struct gxRGBAColor{
      gxColorValue   red;
      gxColorValue   green;
      gxColorValue   blue;
      gxColorValue   alpha;
   };
   struct gxHSVColor{
      gxColorValue   hue;
      gxColorValue   saturation;
      gxColorValue   value;
   };
   struct gxHLSColor{
      gxColorValue   hue;
      gxColorValue   lightness;
      gxColorValue   saturation;
   };
   struct gxXYZColor {
      gxColorValue   x;
      gxColorValue   y;
      gxColorValue   z;
   };
   struct gxYXYColor {
      gxColorValue   capY;
      gxColorValue   x;
      gxColorValue   y;
   };
   struct gxLUVColor {
      gxColorValue   l;
      gxColorValue   u;
      gxColorValue   v;
   };
   struct gxLABColor {
      gxColorValue   l;
      gxColorValue   a;
      gxColorValue   b;
   };
   struct gxYIQColor{
      gxColorValue   y;
      gxColorValue   i;
      gxColorValue   q;
   };
   struct gxGrayAColor{
      gxColorValue   gray;
      gxColorValue   alpha;
   };
   typedef long gxColorIndex;

   struct gxIndexedColor{
      gxColorIndex   index;
      gxColorSet     set;
   };

The Color Structure

struct gxColor{
   gxColorSpace         space;
   gxColorProfile       profile;
   union {
         struct gxCMYKColor      cmyk;
         struct gxRGBColor       rgb;
         struct gxRGBAColor      rgba;
         struct gxHSVColor       hsv;
         struct gxHLSColor       hls;
         struct gxXYZColor       xyz;
         struct gxYXYColor       yxy;
         struct gxLUVColor       luv;
         struct gxLABColor       lab;
         struct gxYIQColor       yiq;
         gxColorValue            gray;
         struct gxGrayAColor     graya;
         unsigned short          pixel16;
         unsigned long           pixel32;
         struct gxIndexedColor   indexed;
         gxColorValue            component[4];
   } element;
};

Color Packing

typedef enum {
   gxNoColorPacking     = 0x0000,   /* 16 bits/channel */
   gxAlphaSpace         = 0x0080,   /* space includes alpha channel */
   gxWord5ColorPacking  = 0x0500,   /* 5 bits/channel, right-justified */
   gxLong8ColorPacking  = 0x0800,   /* 8 bits/channel, right-justified */
   gxLong10ColorPacking = 0x0a00,   /* 10 bits/channel, right-justified */
   gxAlphaFirstPacking  = 0x1000    /* alpha channel = 1st field in space */
} gxColorPackingTypes;

Color Spaces

enum gxColorSpaces{
   gxNoSpace      = 0,
   gxRGBSpace,
   gxCMYKSpace,
   gxHSVSpace,
   gxHLSSpace,
   gxYXYSpace,
   gxXYZSpace,
   gxLUVSpace,
   gxLABSpace,
   gxYIQSpace,
   gxNTSCSpace    = gxYIQSpace,
   gxPALSpace     = gxYIQSpace,
   gxGraySpace,
   gxIndexedSpace,
   gxRGBASpace    = gxRGBSpace + gxAlphaSpace,
   gxGrayASpace   = gxGraySpace + gxAlphaSpace,
   gxRGB16Space   = gxWord5ColorPacking + gxRGBSpace,
   gxRGB32Space   = gxLong8ColorPacking + gxRGBSpace,
   gxARGB32Space  = gxLong8ColorPacking + gxAlphaFirstPacking 
                     + gxRGBASpace,
   gxCMYK32Space  = gxLong8ColorPacking + gxCMYKSpace,
   gxHSV32Space   = gxLong10ColorPacking + gxHSVSpace,
   gxHLS32Space   = gxLong10ColorPacking + gxHLSSpace,
   gxYXY32Space   = gxLong10ColorPacking + gxYXYSpace,
   gxXYZ32Space   = gxLong10ColorPacking + gxXYZSpace,
   gxLUV32Space   = gxLong10ColorPacking + gxLUVSpace,
   gxLAB32Space   = gxLong10ColorPacking + gxLABSpace,
   gxYIQ32Space   = gxLong10ColorPacking + gxYIQSpace,
   gxNTSC32Space  = gxYIQ32Space,
   gxPAL32Space   = gxYIQ32Space,
};

typedef long gxColorSpace;

The Color Set Object

typedef struct gxPrivateColorSetRecord *gxColorSet;

The gxSetColor Union

union gxSetColor{
   gxCMYKColor    cmyk;
   gxRGBColor     rgb;
   gxRGBAColor    rgba;
   gxHSVColor     hsv;
   gxHLSColor     hls;
   gxXYZColor     xyz;
   gxYXYColor     yxy;
   gxLUVColor     luv;
   gxLABColor     lab;
   gxYIQColor     yiq;
   gxColorValue   gray;
   gxGrayAColor   graya;
   unsigned short pixel16;
   unsigned long  pixel32;
   gxColorValue   component[4];
};

The Color Profile Object

typedef struct gxPrivateProfileRecord *gxColorProfile;

Color Functions

boolean GXCheckColor		(const gxColor *source, gxColorSpace space, 
				gxColorSet aSet, gxColorProfile profile);
Fixed GXGetColorDistance	(const gxColor *target, const gxColor *source);
gxColor *GXCombineColor		(gxColor *target, gxInk operand);
gxColor *GXConvertColor		(gxColor *target, gxColorSpace space, 
				gxColorSet aSet, gxColorProfile profile);

Color Set Functions

Creating and Manipulating Color Set Objects

gxColorSet GXGetDefaultColorSet
				(long pixelDepth);
void GXSetDefaultColorSet	(gxColorSet target, long pixelDepth);
gxColorSet GXNewColorSet	(gxColorSpace space, long count, 
				const gxSetColor colors[]);
void GXDisposeColorSet		(gxColorSet target);
gxColorSet GXCopyToColorSet	(gxColorSet target, gxColorSet source);
boolean GXEqualColorSet		(gxColorSet one, gxColorSet two);
gxColorSet GXCloneColorSet	(gxColorSet source);

Manipulating Color Set Object Properties

long GXGetColorSetOwners	(gxColorSet source);
long GXGetColorSetTags		(gxColorSet source, long tagType, long index, 
				long count, gxTag items[]);
void GXSetColorSetTags		(gxColorSet target, long tagType, long index, 
				long oldCount, long newCount, 
				const gxTag items[]);

Retrieving and Replacing Colors in a Color Set

long GXGetColorSet		(gxColorSet source, gxColorSpace *space, 
				gxSetColor colors[]);
void GXSetColorSet		(gxColorSet target, gxColorSpace space, 
				long count, const gxSetColor colors[]);
long GXGetColorSetParts		(gxColorSet source, long index, long count, 
				gxColorSpace *space, gxSetColor data[]);
void GXSetColorSetParts		(gxColorSet target, long index, long oldCount, 
				long newCount, const gxSetColor data[]);

Color Profile Functions

Creating and Manipulating Color Profile Objects

gxColorProfile GXGetDefaultColorProfile
				(void);
gxColorProfile GXNewColorProfile
				(const gxProfileRecord *profile, 
				const gxProfileResponse *responses);
void GXDisposeColorProfile	(gxColorProfile target);
gxColorProfile GXCopyToColorProfile
				(gxColorProfile target, gxColorProfile source);
boolean GXEqualColorProfile	(gxColorProfile one, gxColorProfile two);
gxColorProfile GXCloneColorProfile
				(gxColorProfile source);

Manipulating Color Profile Object Properties

long GXGetColorProfileOwners	(gxColorProfile source);
long GXGetColorProfileTags	(gxColorProfile source, long tagType, 
				long index, long count, gxTag items[]);
void GXSetColorProfileTags	(gxColorProfile target, long tagType, 
long index, long oldCount, long newCount, 
				const gxTag items[]);

Retrieving and Replacing Profile Information

long GXGetColorProfile		(gxColorProfile source, 
gxProfileRecord *profile, 
				gxProfileResponse *responses);
void GXSetColorProfile		(gxColorProfile target,
const gxProfileRecord *profile, 
				const gxProfileResponse *responses);
void GXLockColorProfile		(gxColorProfile source);
void GXUnlockColorProfile	(gxColorProfile source);
void *GXGetColorProfileStructure
				(gxColorProfile source, long *length);


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996